<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class CommonValidate extends CoreValidate {
	
	//constructor
	function CommonValidate() {
		
	}
	
	//	
	function checkNull($data_array, $fields) {
		if( !is_array($data_array) ) {
			return true;
		}
		foreach($data_array as $k => $v) {
			if( substr($k, 0, strlen('field_')) == 'field_' ) {
				$kb = substr($k, strlen('field_'));
			}
			if( (in_array($k, $fields) || in_array($kb, $fields)) && $this->_str_eq($data_array[$k], 0) == true ) {
				$this->_result_valid = false;
			}
		}
	}
	
	function checkEmail($email) {
		if( $this->_valid_email($email) == false ) {
			$this->_result_valid = false;
		}
	}
	
	function checkColor($rgb) {
		$rgb = strtolower($rgb);
		if( strlen($rgb) == 8 && substr($rgb, 0, 2) == '0x' ) {
			$rgb = substr($rgb, 2);
		}
		if( strlen($rgb) == 6 && preg_match("[0-9a-f]", $rgb) ) {
			//$this->_result_valid = true;
		} else {
			$this->_result_valid = false;
		}
	}
}
//
?>